<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>

<body>
    <div id="app">
        <Item :conter="2" @fasong="jieshou"></Item>
        <Item :conter="3" @fasong="jieshou"></Item>
        <div>{{total}}</div>
    </div>
    <script>
        var item = {
            props: ["conter"],
            data() {
                return {
                    num: this.conter
                }
            },
            template: "<div @click='addData'>{{num}}</div>",
            methods: {
                addData() {
                    this.num = this.num + 2;
                    this.$emit("fasong", 2)
                }
            },

        }

        new Vue({
            el: "#app",
            data: {
                total: 5
            },
            methods: {
                jieshou(step) {
                    this.total += step
                }
            },
            components: {
                Item: item
            }
        })
    </script>
</body>

</html>